feat: add Capacitor SQLite persisted collection package#1363
Conversation
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-browser-wa-sqlite-persisted-collection
@tanstack/db-capacitor-sqlite-persisted-collection
@tanstack/db-cloudflare-do-sqlite-persisted-collection
@tanstack/db-electron-sqlite-persisted-collection
@tanstack/db-expo-sqlite-persisted-collection
@tanstack/db-ivm
@tanstack/db-node-sqlite-persisted-collection
@tanstack/db-react-native-sqlite-persisted-collection
@tanstack/db-sqlite-persisted-collection-core
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: 0 B Total Size: 110 kB ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 4.23 kB ℹ️ View Unchanged
|
741845b to
90e3a4c
Compare
95f4d17 to
56598ba
Compare
kevin-dp
left a comment
There was a problem hiding this comment.
PR Review: #1363 — feat: add Capacitor SQLite persisted collection package
Overall
Solid PR. The package structure, public API, test coverage (all four contract suites + bespoke tests + native e2e on both iOS and Android), and persistence wiring all follow established patterns correctly. The README has useful Capacitor-specific platform notes.
Issues to address
capacitor-sqlite-driver.ts:28 — Missing optional chaining on process.versions
return typeof process.versions.node === `string`In Capacitor's webview, process may be polyfilled (e.g., by Vite/webpack) but process.versions could be undefined, which would throw at runtime. Should be process.versions?.node.
Worth considering
-
close()always closes the database — Since the caller creates and owns theSQLiteDBConnectionexternally, having the driver'sclose()unconditionally calldatabase.close()could surprise callers who share a connection across multiple drivers. Consider either documenting this or leavingclose()as a no-op and letting the caller manage the connection lifecycle. -
e2e/app/src/runtime-vitest.ts(545 lines) — This custom test runner is a significant piece of infrastructure. If other native runtime packages need similar e2e harnesses in the future, it may be worth extracting into a shared package rather than duplicating. -
tsconfig.jsonincludes"jsx": "react"— No JSX in this package; unnecessary.
Summary
Approve with one fix — the process.versions?.node optional chaining bug. The rest are minor suggestions.
56598ba to
dc926cc
Compare
Add a Capacitor SQLite runtime wrapper so persisted collections can reuse the shared core adapter and test coverage pattern across runtimes. Made-with: Cursor
Move the Capacitor persisted-collection runtime harness into the package, run the full conformance suite in a native iOS app, and share the suite registration lifecycle across the shimmed and native e2e paths. Made-with: Cursor
Extend the shared Capacitor test app to support Android, add a host runner that boots or reuses an emulator and reads the native SQLite results database, and document the new Android e2e workflow. Made-with: Cursor
Pass the detected Android SDK through native build commands, guard the Android runner's piped subprocess output, and align the shared harness teardown hook with the e2e contract's real cleanup path. Made-with: Cursor
Guard Node AsyncLocalStorage detection for polyfilled process objects in Capacitor webviews, and document close() ownership semantics. Add a regression test and refresh pnpm-lock.yaml so workspace installs are reproducible. Made-with: Cursor
8cd76ae to
c1b8b06
Compare
…-capacitor Made-with: Cursor # Conflicts: # pnpm-lock.yaml
Summary
@tanstack/db-capacitor-sqlite-persisted-collectionpackage with the Capacitor SQLite driver, persistence factory, tests, and READMEpackages/db-capacitor-sqlite-persisted-collection/e2e/appand run the full persisted collection conformance suite inside a real Capacitor iOS appTest plan
pnpm --filter @tanstack/db-capacitor-sqlite-persisted-collection testpnpm --filter @tanstack/db-capacitor-sqlite-persisted-collection test:e2epnpm --filter @tanstack/db-capacitor-sqlite-persisted-collection test:e2e:iospnpm --filter @tanstack/db-capacitor-sqlite-persisted-collection test:e2e:androidMade with Cursor